package com.example.redis;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Optional;

public class OptionalTest {

    public static void main(String[] args) {
        User user=null;
        User yu = Optional.ofNullable(user).orElseGet(() -> new User("yu"));
        System.out.println(yu);
    }
}
@Data
@AllArgsConstructor
@NoArgsConstructor
class User{
    private String name;
}
